package com.example.wineknower.utils;

import android.content.Context;
import android.content.SharedPreferences;

public   final  class UserUtil {
	public static final String USER_ID = "userid";
	public static final String USER_NAME = "username";
	public static final String IMAGE_URL = "url";
	public static final String OPEN_ID = "openid";

	public  static  SharedPreferences sp;
	public  static SharedPreferences.Editor editor;

	public UserUtil(Context context){
		sp = context.getSharedPreferences("my_sp", Context.MODE_PRIVATE);
		editor = sp.edit();
	}


	public static String getUserId() {
		return sp.getString(USER_ID, "");
	}
	public static void setUserId(String userId) {
		editor.putString(USER_ID, userId);
		editor.commit();
	}
	public static String getUserName() {
		return sp.getString(USER_NAME, "请登录");
	}
	public static void setUserName(String userName) {
		editor.putString(USER_NAME, userName);
		editor.commit();
	}
	public static String getImageUrl() {
		return sp.getString(IMAGE_URL, "");
	}
	public static void setImageUrl(String imageUrl) {
		editor.putString(IMAGE_URL, imageUrl);
		editor.commit();
	}
	public static String getOpenId() {
		return sp.getString(OPEN_ID, "");
	}
	public static void setOpenId(String openId) {
		editor.putString(OPEN_ID, openId);
		editor.commit();
	}

}
